package test0819;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/8/20
 * Time:14:12
 **/
public class Main3 {
/*
 * 题目要求：在给定的数组中，查找出现次数最多的数组元素和其出现的次数
 * */

    /**
     * @param args
     */
    public static void main(String[] args) {
        Character[] array = {'a','b','a','b','c','d','1','d','2'};

        HashMap<Character, Integer> map = new HashMap<>();

        for (int i = 0; i < array.length; i++) {
            if (map.containsKey(array[i])) {
                int temp = map.get(array[i]);
                map.put(array[i], temp + 1);
            } else {
                map.put(array[i], 1);
            }
        }
    }

}